<template>
    <div>
        登录
        <button @click="login">login</button>
    </div>
</template>

<script>
import { login as loginFn } from "@/api/user/login.js"
import { SET_TOKEN } from "@/utils/token.js"
    export default {
        data() {
            return {
                data:{
                    account:"admin",
                    password:"admin"
                }
            }
        },
        methods: {
            login(){
                loginFn(this.data).then(res=>{
                    console.log(res.data.token);
                    SET_TOKEN(res.data.token)
                    this.$router.replace("/")
                })
            }
        },
    }
</script>

<style lang="scss" scoped>

</style>